inp, s, steps = input(), "", 0

for i in inp:
    if i == '(' or i == '[' or i == '{' or i == '<':
        s += i
        steps += 1
        
    if len(s) > 0:
        if i == ')' and s[-1] == '(':
            s = s[:-1]
            steps += 1
        elif i == ']' and s[-1] == '[':
            s = s[:-1]
            steps += 1
        elif i == '}' and s[-1] == '{':
            s = s[:-1]
            steps += 1
        elif i == '>' and s[-1] == '<':
            s = s[:-1]
            steps += 1

if len(s) == 0 and len(inp) == steps: print('True')
else: print('False')